from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By


def login(driver, username, password,code):
    # 1 进入登录页面
    driver.find_element(by=By.LINK_TEXT, value="登录").click()
    # 2 输入信息
    driver.find_element(by=By.ID, value="username").send_keys(username)
    driver.find_element(by=By.ID, value="password").send_keys(password)
    driver.find_element(by=By.ID, value="verify_code").send_keys(code)
    # 3 点击登录
    driver.find_element(by=By.LINK_TEXT, value="登    录").click()

def search(driver, keyword):
    # 输入内容
    driver.find_element(by=By.ID, value="q").send_keys(keyword)
    # 点击搜索按钮
    driver.find_element(by=By.CLASS_NAME, value="ecsc-search-button").click()

# 电脑--> 鼠标悬浮 --> 点击手写板
def click_search( driver):
    action = ActionChains(driver)
    # 鼠标悬浮于电脑上
    action.move_to_element(driver.find_element(by=By.XPATH, value="/html/body/div[1]/div[3]/div/div[2]/div/div[3]/div[1]/h3/div/a")).perform()
    # 点击手写板
    driver.find_element(by=By.LINK_TEXT, value="手写板").click()




